<template>
  <view class="good-list">
    <uni-list class="iconList">
      <uni-list-item
        v-for="(item, index) in list"
        :key="index"
        :title="item.title"
        clickable
        style="width: 100%"
        @click="clickItem(item)"
      >
        <view slot="body" class="lz-list-body">
          <view class="lz-list-title lz-ellipsis-1">{{$t('签约方名称')}}：{{ item.partnerName }}</view>
          <view class="lz-list-item lz-ellipsis-1">
            {{$t('证件类型')}}：{{ computerDocumentType(item.identTypeCode) }}
          </view>
          <view class="lz-list-item lz-ellipsis-1">{{$t('证件号码')}}：{{ item.identNo }}</view>
          <view class="lz-list-item lz-ellipsis-1">
            {{$t('手机号')}}：
            <view style="width: 400rpx">
              <u-input
                v-model="item.phone"
                :border-color="item.isRed === true ? 'red' : ''"
                border
                height="55"
               :placeholder="$t('请输入手机号')"
                type="text"
                @input="changeInput(item)"
              />
            </view>
          </view>
        </view>
        <view slot="footer" class="lz-list-footer">
          <u-tag mode="dark" size="mini" :text="$t('选取')" type="primary" />
        </view>
      </uni-list-item>
    </uni-list>
  </view>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex'

export default {
  props: {
    list: {
      type: Array,
      default() {
        return []
      }
    },
    option: {
      //当前页面信息，从哪里点进的
      type: Object,
      default() {
        return {}
      }
    },
    titleName: {
      //当前tab名称
      type: String,
      default() {
        return ''
      }
    }
  },
  computed: {
    ...mapGetters(['userInfo', 'api', 'documentTypeList']),
    computerDocumentType() {
      return (code) => {
        let item = this.documentTypeList.find((item) => item.value === code)
        return item.label
      }
    }
  },
  data() {
    return {}
  },
  mounted() {
  },
  methods: {
    changeInput(row) {
      if (row.phone && !this.$u.test.mobile(row.phone)) {
        row.isRed = true
      } else {
        row.isRed = false
      }
    },
    //选取
    clickItem(row) {
      if (!row.phone || !this.$u.test.mobile(row.phone)) {
        this.$set(row, 'isRed', true)
      } else {
        this.$set(row, 'isRed', false)
        this.$emit('clickItem', row)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.good-list {
  background-color: #fff;
  width: 100%;

  .u-tag {
    margin-bottom: 5px;
    margin-right: 5px;
  }

  .lz-list-item {
    display: flex;
    align-items: center;
  }
}
</style>
